<template>
  <div class="heade">
    <!-- <div class="top">
      <el-dropdown class="right">
        <i class="el-icon-user"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item @click.native="toLogin" v-if="userId == 0">登录</el-dropdown-item>
          <el-dropdown-item @click.native="Personal"> 个人中心</el-dropdown-item>
          <el-dropdown-item @click.native="LoginOut" v-if="userId != 0">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div> -->

  </div>
</template>

<script>
import { getUserMessage } from '@/js/usermessage'
export default {
  data() {
    return {
      userId: 0
    }
  },
  created() {
    getUserMessage()
    this.getUserid()
  },

  methods: {
    toLogin() {
      this.$router.push('/login')
    },


    //退出登录
    LoginOut() {
      localStorage.removeItem("user")
      this.$router.push("/login")
      this.$notify.success("退出成功！")
    },

    getUserid() {
      this.userId = getUserMessage(this.userId)
    },

    Personal() {
      this.$router.push({
        query: {
          userId: this.userId
        },
        path: "/Personal"
      })
    }
  }
}
</script>

<style scoped>
.top {
  /* background-color: rgba(227, 228, 229); */
  width: 100%;
  height: 33px;
}

.heade {
  position: absolute;
  right: 7px;
  top: 43px;
}

.top .right {
  float: right;
  margin: 2px 10px 2px 0;
  right: 0px;
  font-size: 25px;
}

.top img {
  float: left;
  width: 20px;
  height: 20px;
  margin: 7px 0 2px 15px;
}
</style>